import org.apache.spark.{SparkConf, SparkContext}

object laz02 {
  def main(args: Array[String]): Unit = {

    val conf = new SparkConf().setAppName("Teacher").setMaster("local[*]")
    val sc = new SparkContext(conf)

    val dataRDD = sc.textFile("teacher.log")


    val resultRDD = dataRDD
      .map(line => line.split("/")(3))
      .map(teacher => (teacher, 1))
      .reduceByKey(_ + _)

    resultRDD.collect().foreach{case (teacher, count) =>
      println(s"（$teacher，$count）")}

    sc.stop()
  }
}